$(function() {

    var page = 1;
    var pageSize = 5;

    $.ajax({
        url: '/user/queryUser',
        type: 'get',
        data: {
            page: page,
            pageSize: pageSize,
        },
        success: function(res) {
            console.log(res);
            var html = template('dataTpl', res);
            $('.table').html(html);
        }
    });


    $('.table').on('click', '#btns', function() {

        var isDelete = $(this).attr('id-isDelete');

        var id = $(this).attr('data-id');
        // console.log(id);

        $.ajax({
            url: '/user/updateUser',
            type: 'POST',
            data: {
                id: id,
                isDelete: isDelete == 0 ? 1 : 0
            },
            success: function(res) {
                // console.log(res);
                if (res.success) {
                    location.reload();
                }

            }
        });
    })


});